﻿using EasyWakeOnLan;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;

namespace WolServer.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;

        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
        }

        [HttpPost]
        public async Task<JsonResult> SendWol([FromQuery]string mac)
        {
            using (var client = new EasyWakeOnLanClient())
            {
                await client.WakeAsync(mac);
                return Json(new { Msg = "发生成功" });
            }
        }

    }
}
